local Player = class("Player")

function Player:ctor()
	self.uuid = nil
	self.users = nil
	self.leader = nil
	self.position = {x = 0}
	self.followNums = 0
	self.update = false
end

function Player:read(params,pUsers)
	self.uuid = params.uuid
	self.followNums = 0
	if params.users then
		self.users = (self.users == nil) and {} or self.users
		for i,v in ipairs(params.users) do
			local user = self.users[v.uid]
			if user then
				user:read(v)
			else
				self.users[v.uid] = UserBaseInfo.new(v)
			end
			if i == 1 then
				self.leader = self.users[v.uid]
			end
			self.users[v.uid].xOrder = i
			self.users[v.uid].update = true
			self.users[v.uid].create = true
			self.followNums = self.followNums + 1

			pUsers[v.uid] = self.users[v.uid]
		end
		for k,v in pairs(self.users) do
			if not v.update then
				self.users[k] = nil
			end
		end
	end
	self.position.x = params.position and params.position.x or 0
	self.update = true
end

function Player:isUpdate()
	return self.update
end

function Player:setUpdate(update)
	self.update = update
end

function Player:getX()
	return self.position.x
end

function Player:getUsers()
	return self.users
end

function Player:getFollowNums()
	return self.followNums
end

return Player